import com.adobe.cairngorm.control.CairngormEventDispatcher;

import mx.events.CloseEvent;
import mx.events.ValidationResultEvent;
import mx.managers.PopUpManager;

import net.optix.ip.events.RenewalFeeEvent;
import net.optix.ip.model.ModelLocator;
import net.optix.ip.vo.RenewalFeeVO;

[Bindable]
private var model:ModelLocator	=	ModelLocator.getInstance();

public function init():void
{
	model.bSubmit	=	true;
	model.result	=	"";
 	model.close		=	"no";
}
  			
private function titleWindow_close(evt:CloseEvent):void 
{ 
	model.result	=	"";
 	model.bSubmit	=	true;
  	PopUpManager.removePopUp(this); 
}

private function renewalFee():void
{
	var result:Boolean	=	true;

	var resultValidate:ValidationResultEvent;
				
	resultDate.text	=	"";
	resultNumber.text=	"";
				
	resultValidate	=	stringValidator.validate(renewalDate.text);
    if(resultValidate.type == ValidationResultEvent.INVALID)
    {
      	result	=	false;
    	resultDate.text	=	resultValidate.message;
   	} 
   	
   	resultValidate	=	stringValidator.validate(referenceNumber.text);
    if(resultValidate.type == ValidationResultEvent.INVALID)
    {
      	result	=	false;
    	resultNumber.text	=	resultValidate.message;
   	} 
   	
   	if(result	==	true)
   	{
   		model.result	=	"Sending information to server ...";
   		var vo:RenewalFeeVO	=	new RenewalFeeVO();
   		vo.firmID			=	model.firm.firmID;
   		vo.inventionID		=	model.currentInvention.inventionID;
   		vo.renewalDate		=	renewalDate.text;
   		vo.referenceNumber	=	referenceNumber.text;
   		
   		var event:RenewalFeeEvent	=	new RenewalFeeEvent(vo);
   		com.adobe.cairngorm.control.CairngormEventDispatcher.getInstance().dispatchEvent(event);
   	}
}